﻿#pragma once
#include<qthread.h>
#include <qdir.h>
#include <QtWidgets/QDialog>
#include "ui_Osgb23DTiles.h"


class RunThread : public QThread
{
	Q_OBJECT
signals:
	void notify(int);
	void notifyDone(long);
public:
	RunThread(QObject *parent = 0) : QThread(parent)
	{
	};
	void setPath(QDir inpath, QDir outpath) {
		_inpath = inpath;
		_outpath = outpath;
	}
	void setCenter(double x, double y) {
		centerx = x;
		centery = y;
	}
	void setMaxlvl(int l) {
		maxlvl = l;
	}
	void setMinhight(double h) {
		minh = h;
	}
protected:
	void run();
private:
	QDir _inpath;
	QDir _outpath;
	double centerx;
	double centery;
	int maxlvl;
	double minh;
};

class Osgb23DTiles : public QDialog
{
	Q_OBJECT
public:
	Osgb23DTiles(QWidget *parent = Q_NULLPTR);
	~Osgb23DTiles();
	void updateMessage(std::string msg) {
		ui.textBrowser->append(QString::fromStdString(msg));
	}
	public
	slots:
	void updateMessage2(const char* msg) {
		ui.textBrowser->append(QString::fromStdString(msg));
	}
private:
	void convert_osgb(QString osgb_dir, QString tile_dir);
private slots:
	void on_pBtnOpenPath_clicked();
	void on_pBtnOutputPath_clicked();
	void on_pBtnStart_clicked();
	void updateProgressBarNotify(int i)
	{
		ui.progressBar->setValue(i);
	};
	void updateDone(long time)
	{
		ui.pBtnStart->setEnabled(true);
		ui.textBrowser->setText(QString::fromLocal8Bit("耗时：") + QString::number(time) + QString(" ms"));
	};

private:

	Ui::Osgb23DTiles ui;
	RunThread convetThread;

};

